import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-06-24
 * Time: 23:12
 */
public class Test3 {

    public static int longestConsecutive(int[] num) {
        Set<Integer> hash = new HashSet<>();
        for(int x : num) {
            hash.add(x);
        }
        int longSize = 0;
        for(int x : hash) {
            if(!hash.contains(x-1)) {
                int curSize = 1;
                int curNum = x;

                while(hash.contains(curNum+1)) {
                    curNum++;
                    curSize++;
                }
                longSize = Math.max(longSize,curSize);
            }
        }
        return longSize;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] num =  new int[n];
        for(int i = 0; i < n; i++) {
            num[i] = sc.nextInt();
        }
        System.out.println(longestConsecutive(num));
    }
}
